package main

import (
	"database/sql"
	"fmt"
	"log"
	"local.dev/sqlmaker/config"
	"local.dev/sqlmaker"
)

func main() {
	cfg, err := config.LoadConfig("config/config.yaml")
	if err != nil {
		log.Fatal("配置加载失败:", err)
	}

	db, err := sqlmaker.Connect(cfg)
	if err != nil {
		log.Fatal("数据库连接失败:", err)
	}
	defer db.Close()

	rows, err := db.Query("SELECT id, name FROM users WHERE age > ?", 18)
	if err != nil {
		log.Fatal("查询失败:", err)
	}
	defer rows.Close()

	for rows.Next() {
		var id int
		var name string
		if err := rows.Scan(&id, &name); err != nil {
			log.Fatal("结果解析失败:", err)
		}
		fmt.Printf("ID: %d, Name: %s\n", id, name)
	}
}